//
//  MainRole.m
//  ZeroWorld
//
//  Created by 马进 on 2018/2/9.
//  Copyright © 2018年 马进. All rights reserved.
//

#import "MainRole.h"
#import "MapBlock.h"
@implementation MainRole

- (void)look {
    [self look:nil];
}

- (void)feel {
    //触发式被动感觉
}

- (void)feel:(NSObject *)sth {
    if ([sth isKindOfClass:[MapBlock class]]) {
        MapBlock *b = (MapBlock *)sth;
        self.currentPalace = b;
        [self look];
    }
}

- (void)look:(NSObject *)something {
    if (something == nil) {
        NSString *string = [NSString stringWithFormat:@"你来到了%@", self.currentPalace.name];
        [self output:string];
    }
}

- (NSString *)directionString:(MapDirection)d {
    if (d == MapDirectionNorth) {
        return @"北";
    }
    else if (d == MapDirectionSouth) {
        return @"南";
    }
    else if (d == MapDirectionEast) {
        return @"东";
    }
    else if (d == MapDirectionWest) {
        return @"西";
    }
    else {
        return @"不明";
    }
}

- (void)move: (MapDirection)direction {
    MapBlock *b = [self.currentPalace lookForWay:direction];
    [self output:[NSString stringWithFormat:@"\n你尝试向%@方移动...", [self directionString:direction]]];
    if (b == nil) {
        [self output:@"这个方向已经没有路了..."];
    }
    else {
        [b enter:self];
    }
}

- (void)say :(NSObject *)someThing {
    [self say:someThing to:nil];
}

- (void)say :(NSObject *)someThing to:(NSObject *)somebody {
    
}

// 要输出到屏幕上的信息
- (void)output : (NSString *)string{
    if (string.length > 0) {
        if (self.delegate && [self.delegate respondsToSelector:@selector(mainRoleTextOutPut:)]) {
            [self.delegate mainRoleTextOutPut:string];
        }
    }
}
@end
